//
//  AlertView.m
//  Kaagad Peso
//
//  Created by ZhengChengFeng on 2024/10/16.
//

#import "AlertView.h"

#define kBottomFixHeight  (IS_IPhoneX_All ? kHeight_BottomSafe : 20)

@implementation AlertView

- (instancetype)initWithFrame:(CGRect)frame withTitleStr:(NSString *)title withCancelStr:(NSString *)cancelStr withSureStr:(NSString *)sureStr{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = kShadowViewColor;
        
        CGFloat kAlertViewWidth = kScreenWidth  - 120;
        
        CGSize size = [NSString textSizeWithText:title font:[UIFont fontWithName:kFuturaMedium size:13] numberOfLines:0 lineSpacing:3 constrainedWidth:kAlertViewWidth - DimensionBaseIphone6(24) - DimensionBaseIphone6(24)];

        
        CGFloat alertH = DimensionBaseIphone6(33 + 25 + 44 + size.height + 2);
        
        self.alertView = [[UIView alloc]init];
        self.alertView.frame = CGRectMake(60, (kScreenHeight - alertH)/2,kScreenWidth - 120,alertH);
        self.alertView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.alertView];
        self.alertView.layer.cornerRadius = 10;
        self.alertView.layer.masksToBounds = YES;
        
        
        UILabel *titleLab = [UILabel createLabel:[UIFont fontWithName:kFuturaMedium size: 13] color:[UIColor colorWithHexString:@"#022D06"]];
        titleLab.text = esString(title);
        titleLab.textAlignment = 1;
        titleLab.numberOfLines = 0;
        titleLab.frame = CGRectMake(DimensionBaseIphone6(24), DimensionBaseIphone6(33), kAlertViewWidth - DimensionBaseIphone6(48), DimensionBaseIphone6(size.height + 2));
        [self.alertView addSubview:titleLab];
        
        self.cancelButton = [[UIButton alloc]init];
        [self.cancelButton setTitle:esString(cancelStr) forState:UIControlStateNormal];
        [self.cancelButton setTitleColor:[UIColor colorWithHexString:@"#638473"] forState:UIControlStateNormal];
        self.cancelButton.titleLabel.font = [UIFont fontWithName:kFuturaMedium size:14];
        [self.cancelButton addTarget:self action:@selector(clickCancelBtn) forControlEvents:UIControlEventTouchUpInside];
        
        self.sureButton = [[UIButton alloc]init];
        [self.sureButton setTitle:esString(sureStr) forState:UIControlStateNormal];
        [self.sureButton setTitleColor:kButtonDefaultColor forState:UIControlStateNormal];
        self.sureButton.titleLabel.font = [UIFont fontWithName:kFuturaMedium size:14];
        [self.sureButton addTarget:self action:@selector(clickSureBtn) forControlEvents:UIControlEventTouchUpInside];
    
        
        UIView *line1 = [[UIView alloc]init];
        [self.alertView addSubview:line1];
        line1.backgroundColor = kLineColor;
        
        UIView *line2 = [[UIView alloc]init];
        
        line2.backgroundColor = kLineColor;
        
        
        [self.alertView addSubview:self.cancelButton];
        [self.alertView addSubview:self.sureButton];
        [self.alertView addSubview:line1];
        [self.alertView addSubview:line2];
        
        self.cancelButton.frame = CGRectMake(0, alertH - DimensionBaseIphone6(44), kAlertViewWidth/2, DimensionBaseIphone6(44));
        self.sureButton.frame = CGRectMake(kAlertViewWidth/2, self.cancelButton.top, kAlertViewWidth/2, DimensionBaseIphone6(44));
        
        line1.frame= CGRectMake(0, self.cancelButton.top - 1, kAlertViewWidth, 1);
        line2.frame= CGRectMake(kAlertViewWidth/2, line1.bottom, 1, DimensionBaseIphone6(44));
        
        
        
    }
    return self;
    
}


- (void)clickCancelBtn{
    if (_clickCancelBlock) {
        _clickCancelBlock();
    }
    [self removeFromSuperview];
}

- (void)clickSureBtn{
    if (_clickSureBlock) {
        _clickSureBlock();
    }
    [self removeFromSuperview];
}

@end

@implementation AlertTokenExpireView

- (instancetype)initWithFrame:(CGRect)frame withTitleStr:(NSString *)title withSureStr:(NSString *)sureStr{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = kShadowViewColor;
        
        CGFloat kAlertViewWidth = kScreenWidth  - 120;
        
        CGSize size = [NSString textSizeWithText:title font:[UIFont fontWithName:kFuturaMedium size:13] numberOfLines:0 lineSpacing:3 constrainedWidth:kAlertViewWidth - DimensionBaseIphone6(24) - DimensionBaseIphone6(24)];

        
        CGFloat alertH = DimensionBaseIphone6(33 + 25 + 44 + size.height + 2);
        
        self.alertView = [[UIView alloc]init];
        self.alertView.frame = CGRectMake(60, (kScreenHeight - alertH)/2,kScreenWidth - 120,alertH);
        self.alertView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.alertView];
        self.alertView.layer.cornerRadius = 10;
        self.alertView.layer.masksToBounds = YES;
        
        
        UILabel *titleLab = [UILabel createLabel:[UIFont fontWithName:kFuturaMedium size: 13] color:[UIColor colorWithHexString:@"#022D06"]];
        titleLab.text = esString(title);
        titleLab.textAlignment = 1;
        titleLab.numberOfLines = 0;
        titleLab.frame = CGRectMake(DimensionBaseIphone6(24), DimensionBaseIphone6(33), kAlertViewWidth - DimensionBaseIphone6(48), DimensionBaseIphone6(size.height + 2));
        [self.alertView addSubview:titleLab];
        
        self.sureButton = [[UIButton alloc]init];
        [self.sureButton setTitle:esString(sureStr) forState:UIControlStateNormal];
        [self.sureButton setTitleColor:kButtonDefaultColor forState:UIControlStateNormal];
        self.sureButton.titleLabel.font = [UIFont fontWithName:kFuturaMedium size:14];
        [self.sureButton addTarget:self action:@selector(clickSureBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.alertView addSubview:self.sureButton];
        
        UIView *line1 = [[UIView alloc]init];
        [self.alertView addSubview:line1];
        line1.backgroundColor = kLineColor;
        [self.alertView addSubview:line1];
       

        self.sureButton.frame = CGRectMake(0, alertH - DimensionBaseIphone6(44), kAlertViewWidth, DimensionBaseIphone6(44));
        
        line1.frame= CGRectMake(0, self.sureButton.top - 1, kAlertViewWidth, 1);
        
        
        
        
    }
    return self;
    
}

- (void)clickSureBtn{
    if (_clickSureBlock) {
        _clickSureBlock();
    }
    [self removeFromSuperview];
}




@end

@implementation AlertGoOutView

- (instancetype)initWithFrame:(CGRect)frame withTitleStr:(nonnull NSString *)title withDescStr:(nonnull NSString *)descStr withCancelStr:(nonnull NSString *)cancelStr withSureStr:(nonnull NSString *)sureStr withIsAccountCancel:(BOOL)isAccCancel{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = kShadowViewColor;
        
        self.isAccCancel = isAccCancel;
        
        CGSize size = [NSString textSizeWithText:descStr font:[UIFont fontWithName:kFuturaMedium size:14] numberOfLines:0 lineSpacing:3 constrainedWidth:kScreenWidth - 60];
        
        CGFloat botFix = IS_IPhoneX_All ? kHeight_BottomSafe : 20;
        CGFloat alertH = DimensionBaseIphone6(60 + 20 + 10 + 33 + 48 + 48 + 15 + botFix + size.height + 2);
        if (isAccCancel) {
            alertH += DimensionBaseIphone6(30);
        }
        
        self.alertView = [[UIView alloc]init];
        self.alertView.frame = CGRectMake(0, kScreenHeight - alertH,kScreenWidth,alertH);
        self.alertView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.alertView];
        self.alertView.layer.mask = [NSString UIBezierPathWithRect:self.alertView.bounds withCorners:UIRectCornerTopLeft|UIRectCornerTopRight withRadiu:CGSizeMake(14, 14)];
        
        self.deleteButton = [[UIButton alloc] initWithFrame:CGRectMake(self.alertView.frame.size.width - 30 - 10, 15, 30, 30)];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateHighlighted];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateSelected];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateNormal];
        [self.deleteButton addTarget:self action:@selector(clickCancelBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.alertView addSubview:self.deleteButton];
        
    
        UILabel *titleLab = [UILabel createLabel:[UIFont fontWithName:kFuturaBold size: 15] color:kBlackColor];
        titleLab.text = esString(title);
        titleLab.frame = CGRectMake(30, DimensionBaseIphone6(60), 200, DimensionBaseIphone6(20));
        [self.alertView addSubview:titleLab];
        
        UILabel *descLab = [UILabel createLabel:[UIFont fontWithName:kFuturaMedium size:14] color:kBlackColor];
        descLab.text = esString(descStr);
        descLab.numberOfLines = 0;
        descLab.frame = CGRectMake(30,  titleLab.bottom + DimensionBaseIphone6(10), kScreenWidth - 60, DimensionBaseIphone6(size.height + 2));
        [self.alertView addSubview:descLab];
        
        
        self.cancelButton = [[UIButton alloc]initWithFrame:CGRectMake(30, descLab.bottom + DimensionBaseIphone6(30), kScreenWidth - 60, DimensionBaseIphone6(48))];
        [self.cancelButton setTitle:esString(cancelStr) forState:UIControlStateNormal];
        [self.cancelButton setImage:[UIImage imageNamed:@"icon_login2"] forState:UIControlStateNormal];
        [self.cancelButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
        self.cancelButton.titleLabel.font = [UIFont fontWithName:kFutura size:15];
        [self.cancelButton addTarget:self action:@selector(clickCancelBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.alertView addSubview:self.cancelButton];
        self.cancelButton.backgroundColor = kButtonDefaultColor;
        self.cancelButton.layer.cornerRadius = DimensionBaseIphone6(24);
        self.cancelButton.layer.masksToBounds = YES;
        [self.cancelButton setImgRightTitltLeft:5];
        
        self.sureButton = [[UIButton alloc]initWithFrame:CGRectMake(30, self.cancelButton.bottom + DimensionBaseIphone6(15), kScreenWidth - 60, DimensionBaseIphone6(48))];
        [self.sureButton setTitle:esString(sureStr) forState:UIControlStateNormal];
        [self.sureButton setImage:[UIImage imageNamed:@"icon_home5"] forState:UIControlStateNormal];
        [self.sureButton setTitleColor:kBlackColor forState:UIControlStateNormal];
        self.sureButton.titleLabel.font = [UIFont fontWithName:kFutura size:15];
        [self.sureButton addTarget:self action:@selector(clickSureBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.alertView addSubview:self.sureButton];
        self.sureButton.backgroundColor = [UIColor colorWithHexString:@"#75FA8D"];
        self.sureButton.layer.cornerRadius = DimensionBaseIphone6(24);
        self.sureButton.layer.masksToBounds = YES;
        [self.sureButton setImgRightTitltLeft:5];
    
        NSString *str = ASLocalizedString(@"AccountCancelTips");
        AgreementView *agreeView = [[AgreementView alloc]initWithTitle:str withTitleColor:[UIColor colorWithHexString:@"#6C6C6C"] protocol:@"" withProtocolColor:kButtonDefaultColor fontSize:12 target:self withSel:NO withAgreeImg:@"icon_agree" withUnagreeImg:@"icon_unagree"];
        agreeView.frame = CGRectMake((kScreenWidth - 200)/2,DimensionBaseIphone6(10) + self.sureButton.bottom, 200, DimensionBaseIphone6(20));
        if (isAccCancel) {
            [self.alertView addSubview:agreeView];
        }
        
        
    }
    return self;
}

- (void)agreeViewWillAgreeProtocol:(BOOL)agree{
    self.isAgree = agree;
}

- (void)clickCancelBtn{
    [self removeFromSuperview];
}

- (void)clickSureBtn{
    if (self.isAccCancel) {
        if (!self.isAgree) {
            [BoxLoadingHelper showBoxWithMessage:ASLocalizedString(@"AccountCancelTips2")];
            return;
        }
    }
    [self removeFromSuperview];
    if (_clickSureBlock) {
        _clickSureBlock();
    }
}

@end



@implementation AlertDCView

- (instancetype)initWithFrame:(CGRect)frame withTitleStr:(nonnull NSString *)title withDescStr:(nonnull NSString *)descStr withCancelStr:(nonnull NSString *)cancelStr withSureStr:(nonnull NSString *)sureStr withIsDC:(BOOL)isDC{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = kShadowViewColor;
        
        CGSize size = [NSString textSizeWithText:descStr font:[UIFont fontWithName:kFuturaMedium size:14] numberOfLines:0 lineSpacing:3 constrainedWidth:kScreenWidth - 60];
        
        CGFloat botFix = IS_IPhoneX_All ? kHeight_BottomSafe : 20;
        CGFloat alertH = 394 + botFix;
        
        
        self.alertView = [[UIView alloc]init];
        self.alertView.frame = CGRectMake(0, kScreenHeight - alertH,kScreenWidth,alertH);
        self.alertView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.alertView];
        self.alertView.layer.mask = [NSString UIBezierPathWithRect:self.alertView.bounds withCorners:UIRectCornerTopLeft|UIRectCornerTopRight withRadiu:CGSizeMake(14, 14)];
        
        self.deleteButton = [[UIButton alloc] initWithFrame:CGRectMake(self.alertView.frame.size.width - 20 - 10, 15, 20, 20)];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateHighlighted];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateSelected];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateNormal];
        [self.deleteButton addTarget:self action:@selector(clickDeleteBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.alertView addSubview:self.deleteButton];
        
    
        UIImage *img = [UIImage imageNamed:@"icon_wlv"];
        if (isDC) {
            img = [UIImage imageNamed:@"icon_dcv"];
        }
        UIImageView *icon = [[UIImageView alloc] initWithFrame:CGRectMake((self.alertView.frame.size.width - img.size.width)/2, 30, img.size.width, img.size.height)];
        [self.alertView addSubview:icon];
        icon.image = img;
        
        if (isDC) {
            UILabel *titleLab = [UILabel createLabel:[UIFont fontWithName:kFuturaBold size:15] color:kBlackColor];
            titleLab.text = esString(title);
            titleLab.frame = CGRectMake(30,  icon.bottom + 10, kScreenWidth - 60, 20);
            [self.alertView addSubview:titleLab];
            
            UILabel *descLab = [UILabel createLabel:[UIFont fontWithName:kFuturaMedium size:14] color:kBlackColor];
            descLab.text = esString(descStr);
            descLab.numberOfLines = 0;
            descLab.frame = CGRectMake(30,  titleLab.bottom, kScreenWidth - 60, size.height + 5);
            [self.alertView addSubview:descLab];
            
            
        } else {
            UILabel *descLab = [UILabel createLabel:[UIFont fontWithName:kFuturaMedium size:14] color:kBlackColor];
            descLab.text = esString(descStr);
            descLab.numberOfLines = 0;
            descLab.frame = CGRectMake(30,  icon.bottom + 10, kScreenWidth - 60, size.height + 5);
            [self.alertView addSubview:descLab];
        }
        
        
        
        self.cancelButton = [[UIButton alloc]initWithFrame:CGRectMake(30, self.alertView.frame.size.height - 48 - botFix, kScreenWidth - 60, 48)];
        [self.cancelButton setTitle:esString(cancelStr) forState:UIControlStateNormal];
        [self.cancelButton setTitle:esString(cancelStr) forState:UIControlStateSelected];
        [self.cancelButton setTitle:esString(cancelStr) forState:UIControlStateHighlighted];
        [self.cancelButton setImage:[UIImage imageNamed:@"icon_home5"] forState:UIControlStateNormal];
        [self.cancelButton setImage:[UIImage imageNamed:@"icon_home5"] forState:UIControlStateSelected];
        [self.cancelButton setImage:[UIImage imageNamed:@"icon_home5"] forState:UIControlStateHighlighted];
        [self.cancelButton setTitleColor:kBlackColor forState:UIControlStateNormal];
        self.cancelButton.titleLabel.font = [UIFont fontWithName:kFutura size:15];
        [self.cancelButton addTarget:self action:@selector(clickCancelBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.alertView addSubview:self.cancelButton];
        self.cancelButton.backgroundColor = [UIColor colorWithHexString:@"#75FA8D"];
        self.cancelButton.layer.cornerRadius = 24;
        self.cancelButton.layer.masksToBounds = YES;
        [self.cancelButton setImgRightTitltLeft:5];
        
        self.sureButton = [[UIButton alloc]initWithFrame:CGRectMake(30, self.cancelButton.top - 15 - 48, kScreenWidth - 60, 48)];
        [self.sureButton setTitle:esString(sureStr) forState:UIControlStateNormal];
        [self.sureButton setTitle:esString(sureStr) forState:UIControlStateSelected];
        [self.sureButton setTitle:esString(sureStr) forState:UIControlStateHighlighted];
        [self.sureButton setImage:[UIImage imageNamed:@"icon_login2"] forState:UIControlStateNormal];
        [self.sureButton setImage:[UIImage imageNamed:@"icon_login2"] forState:UIControlStateSelected];
        [self.sureButton setImage:[UIImage imageNamed:@"icon_login2"] forState:UIControlStateHighlighted];
        [self.sureButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
        self.sureButton.titleLabel.font = [UIFont fontWithName:kFutura size:15];
        [self.sureButton addTarget:self action:@selector(clickSureBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.alertView addSubview:self.sureButton];
        self.sureButton.backgroundColor = kButtonDefaultColor;
        self.sureButton.layer.cornerRadius = 24;
        self.sureButton.layer.masksToBounds = YES;
        [self.sureButton setImgRightTitltLeft:5];
    
        
        
    }
    return self;
}

- (void)clickDeleteBtn{
    [self removeFromSuperview];
}

- (void)clickCancelBtn{
    [self removeFromSuperview];
    if (_clickCancelBlock) {
        _clickCancelBlock();
    }
}

- (void)clickSureBtn{
    [self removeFromSuperview];
    if (_clickSureBlock) {
        _clickSureBlock();
    }
}

@end


@implementation AlertPhotoGuideView

- (instancetype)initWithFrame:(CGRect)frame withFace:(BOOL)isFace{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = kShadowViewColor;
        
            
        CGFloat alertH = 71 + DimensionBaseIphone6(193) + 48 + 20 + kBottomFixHeight;
        
        self.alertView = [[UIView alloc]init];
        self.alertView.frame = CGRectMake(0, kScreenHeight - alertH,kScreenWidth,alertH);
        self.alertView.backgroundColor = [UIColor whiteColor];
        [self addSubview:self.alertView];
        self.alertView.layer.cornerRadius = 10;
        self.alertView.layer.masksToBounds = YES;
        
        
        UILabel *titleLab = [UILabel createLabel:[UIFont fontWithName:kFutura size: 15] color:kBlackColor];
        titleLab.text = ASLocalizedString(@"Photo Example");
        titleLab.frame = CGRectMake(30, 20, 200, 20);
        [self.alertView addSubview:titleLab];
        
        self.deleteButton = [[UIButton alloc] initWithFrame:CGRectMake(self.alertView.frame.size.width - 20 - 10, 15, 20, 20)];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateHighlighted];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateSelected];
        [self.deleteButton setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateNormal];
        [self.deleteButton addTarget:self action:@selector(clickCancelBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.alertView addSubview:self.deleteButton];
        
        self.sureButton = [[UIButton alloc]init];
        [self.sureButton setTitle:ASLocalizedString(@"Confirming") forState:UIControlStateNormal];
        [self.sureButton setTitle:ASLocalizedString(@"Confirming") forState:UIControlStateSelected];
        [self.sureButton setTitle:ASLocalizedString(@"Confirming") forState:UIControlStateHighlighted];
        [self.sureButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
        self.sureButton.titleLabel.font = [UIFont fontWithName:kFuturaMedium size:15];
        [self.sureButton setImage:[UIImage imageNamed:@"icon_login2"] forState:UIControlStateNormal];
        [self.sureButton setImage:[UIImage imageNamed:@"icon_login2"] forState:UIControlStateSelected];
        [self.sureButton setImage:[UIImage imageNamed:@"icon_login2"] forState:UIControlStateHighlighted];
        [self.sureButton addTarget:self action:@selector(clickSureBtn) forControlEvents:UIControlEventTouchUpInside];
        [self.sureButton setImgRightTitltLeft:10];
        self.sureButton.frame = CGRectMake(30, alertH - 48 - kBottomFixHeight, kScreenWidth - 60, 48);
        self.sureButton.layer.cornerRadius = 24;
        self.sureButton.layer.masksToBounds = YES;
        self.sureButton.backgroundColor = kButtonDefaultColor;
        [self.alertView addSubview:self.sureButton];
        [self.sureButton setImgRightTitltLeft:10];
        
        UIImageView *ic1 = [[UIImageView alloc] init];
        [self.alertView addSubview:ic1];
        ic1.image = [UIImage imageNamed:@"icon_idcard9-yn"];
        if (isFace) {
            ic1.image = [UIImage imageNamed:@"icon_idcard10-yn"];
        } 
        
        ic1.frame = CGRectMake(30, 71, kScreenWidth - 60, DimensionBaseIphone6(193));
       
    }
    return self;
    
}


- (void)clickCancelBtn{
    [self removeFromSuperview];
}

- (void)clickSureBtn{
    [self removeFromSuperview];
    if (_clickSureBlock) {
        _clickSureBlock();
    }
    
}

@end


@interface AlertPhotoDataView ()

@property (nonatomic) NSString *nameStr,*idNoStr,*dateStr;

@property (nonatomic) UIView *alertView;

@property (nonatomic) UITextFieldHelper *fullNameFiled,*IDNoFiled,*DateFiled;

@end

#define kWholeViewHeight  (422 + kBottomFixHeight)

@implementation AlertPhotoDataView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = kShadowViewColor;
        
            
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickCacel) name:kNotificationHideAlertView object:nil];
        
        
        
    }
    return self;
    
}


- (void)keyboardShow:(NSNotification *)noti{
    
    NSDictionary *userInfo = [noti userInfo];
    
    NSValue *aValue = [userInfo objectForKey:UIKeyboardFrameEndUserInfoKey];

    CGRect keyboardRect = [aValue CGRectValue];
    
    CGFloat height = keyboardRect.size.height;
    
    CGFloat alertViewHeight = self.alertView.frame.origin.y + self.alertView.size.height;
   
    CGFloat y = height - (kScreenHeight - alertViewHeight);

    if (y > 0) {
        self.frame = CGRectMake(0, -y + DimensionBaseIphone6(80), kScreenWidth, kScreenHeight);
    }
    else{
        self.frame = CGRectMake(0, 0, kScreenWidth,kScreenHeight);
    }

}

- (void)keyboardHide:(NSNotification *)noti{
    self.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
}

- (void)pickViewWithNameStr:(NSString *)nameStr andIDNoStr:(NSString *)idNoStr andDateStr:(NSString *)dateStr{
    self.nameStr = nameStr;
    self.idNoStr = idNoStr;
    self.dateStr = dateStr;
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardShow:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardHide:) name:UIKeyboardWillHideNotification object:nil];
    
    [self createBottomView];
    
}

- (void)createBottomView{
    self.alertView = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight, kScreenWidth, kWholeViewHeight)];
    self.alertView.backgroundColor = kWhiteColor;
    [self addSubview:self.alertView];
    self.alertView.layer.mask = [NSString UIBezierPathWithRect:self.alertView.bounds withCorners:UIRectCornerTopLeft|UIRectCornerTopRight withRadiu:CGSizeMake(14, 14)];
    
    UIImageView *topImgView = [[UIImageView alloc] initWithFrame:CGRectMake(kScreenWidth - 97, 0, 97, 62)];
    [self.alertView addSubview:topImgView];
    topImgView.image = [UIImage imageNamed:@"icon_idcard5"];
    
   
    UILabel *titleLab = [UILabel createLabel:[UIFont fontWithName:kFuturaBold size:15] color:kBlackColor];
    [self.alertView addSubview:titleLab];
    titleLab.frame = CGRectMake(30, 0, 200,62);
    titleLab.text = ASLocalizedString(@"Identity Information");
    
    UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(kScreenWidth - 10 - 20, 10, 20, 20)];
    [cancelBtn setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateNormal];
    [cancelBtn setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateSelected];
    [cancelBtn setImage:[UIImage imageNamed:@"icon_cancel"] forState:UIControlStateHighlighted];
    [cancelBtn addTarget:self action:@selector(clickCacel) forControlEvents:UIControlEventTouchUpInside];
    [self.alertView addSubview:cancelBtn];
    
   
    UIView *nameV = [[UIView alloc] initWithFrame:CGRectMake(30,65, kScreenWidth - 60, 83)];
    nameV.backgroundColor = [UIColor whiteColor];
    [self.alertView addSubview:nameV];
    nameV.layer.cornerRadius = 14;
    nameV.layer.masksToBounds = YES;
    nameV.layer.borderColor = [UIColor colorWithHexString:@"#EFEFEF"].CGColor;
    nameV.layer.borderWidth = 1;
    
    UILabel *labName = [UILabel createLabel:[UIFont fontWithName:kFutura size:14] color:[UIColor colorWithHexString:@"#6C6C6C"]];
    labName.text = ASLocalizedString(@"Aadhaar Name");
    [nameV addSubview:labName];
    labName.frame = CGRectMake(15, 15, 200, 20);
    
    self.fullNameFiled = [[UITextFieldHelper alloc] initWithFrame:CGRectMake(labName.left, labName.bottom,nameV.width - 30, 45)];
    [nameV addSubview:self.fullNameFiled];
    self.fullNameFiled.textColor = kBlackColor;
    self.fullNameFiled.font = [UIFont fontWithName:kFuturaBT size:14];
    
    
    UIView *numberV = [[UIView alloc] initWithFrame:CGRectMake(30,nameV.bottom + 15, kScreenWidth - 60, 83)];
    numberV.backgroundColor = [UIColor whiteColor];
    [self.alertView addSubview:numberV];
    numberV.layer.cornerRadius = 14;
    numberV.layer.masksToBounds = YES;
    numberV.layer.borderColor = [UIColor colorWithHexString:@"#EFEFEF"].CGColor;
    numberV.layer.borderWidth = 1;
    
    UILabel *labNumber = [UILabel createLabel:[UIFont fontWithName:kFutura size:14] color:[UIColor colorWithHexString:@"#6C6C6C"]];
    labNumber.text = ASLocalizedString(@"Aadhaar Number");
    [numberV addSubview:labNumber];
    labNumber.frame = CGRectMake(15, 15, 200,20);
    
    self.IDNoFiled = [[UITextFieldHelper alloc] initWithFrame:CGRectMake(labNumber.left, labNumber.bottom,numberV.width - 30, 45)];
    [numberV addSubview:self.IDNoFiled];
    self.IDNoFiled.textColor = kBlackColor;
    self.IDNoFiled.font = [UIFont fontWithName:kFuturaBT size:14];
    self.IDNoFiled.keyboardType = UIKeyboardTypeNumberPad;
    
    
    
    UIView *dateV = [[UIView alloc] initWithFrame:CGRectMake(30,numberV.bottom + 15, kScreenWidth - 60, 83)];
    dateV.backgroundColor = [UIColor whiteColor];
    [self.alertView addSubview:dateV];
    dateV.layer.cornerRadius = 14;
    dateV.layer.masksToBounds = YES;
    dateV.layer.borderColor = [UIColor colorWithHexString:@"#EFEFEF"].CGColor;
    dateV.layer.borderWidth = 1;
    
    UILabel *labDate = [UILabel createLabel:[UIFont fontWithName:kFutura size:14] color:[UIColor colorWithHexString:@"#6C6C6C"]];
    labDate.text = ASLocalizedString(@"Birthday");
    [dateV addSubview:labDate];
    labDate.frame = CGRectMake(15, 15, 200, 20);
    
    self.DateFiled = [[UITextFieldHelper alloc] initWithFrame:CGRectMake(labDate.left, labDate.bottom,dateV.width - 30, 45)];
    [dateV addSubview:self.DateFiled];
    self.DateFiled.textColor = kBlackColor;
    self.DateFiled.placeholder = @"";
    self.DateFiled.font = [UIFont fontWithName:kFuturaBT size:14];
    self.DateFiled.userInteractionEnabled = NO;
    self.DateFiled.keyboardType = UIKeyboardTypeNumberPad;
    
    
    UIImageView *rightImgV = [[UIImageView alloc] initWithFrame:CGRectMake(dateV.frame.size.width - 15 - 11, 0, 11, 8)];
    rightImgV.centerY = self.DateFiled.centerY;
    [dateV addSubview:rightImgV];
    rightImgV.image = [UIImage imageNamed:@"icon_idcard8"];
    
    
    
    UIView *shadeV = [[UIView alloc] initWithFrame:self.DateFiled.frame];
    shadeV.userInteractionEnabled = YES;
    shadeV.backgroundColor = [UIColor clearColor];
    [dateV addSubview:shadeV];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickDate)];
    [shadeV addGestureRecognizer:tap];
    
    
    UIButton *redBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, dateV.bottom, kScreenWidth, 30)];
    [redBtn setTitle:ASLocalizedString(@"IdentityTips") forState:UIControlStateNormal];
    [redBtn setTitle:ASLocalizedString(@"IdentityTips") forState:UIControlStateSelected];
    [redBtn setTitle:ASLocalizedString(@"IdentityTips")forState:UIControlStateHighlighted];
    redBtn.titleLabel.font = [UIFont fontWithName:kFuturaMedium size:12];
    [redBtn setTitleColor:[UIColor colorWithHexString:@"#FF7171"] forState:UIControlStateNormal];
    [redBtn setTitleColor:[UIColor colorWithHexString:@"#FF7171"] forState:UIControlStateSelected];
    [redBtn setTitleColor:[UIColor colorWithHexString:@"#FF7171"] forState:UIControlStateHighlighted];
    [self.alertView addSubview:redBtn];
    redBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    
    UIButton *sureButton = [[UIButton alloc]init];
    [sureButton setTitle:ASLocalizedString(@"Confirming") forState:UIControlStateNormal];
    [sureButton setTitleColor:kWhiteColor forState:UIControlStateNormal];
    sureButton.titleLabel.font = [UIFont fontWithName:kFuturaMedium size:15];
    [sureButton setImage:[UIImage imageNamed:@"icon_login2"] forState:UIControlStateNormal];
    [sureButton addTarget:self action:@selector(clickConfirmBtn) forControlEvents:UIControlEventTouchUpInside];
    [sureButton setImgRightTitltLeft:10];
    sureButton.frame = CGRectMake(30, self.alertView.height - 48 - kBottomFixHeight, kScreenWidth - 60, 48);
    sureButton.layer.cornerRadius = 24;
    sureButton.layer.masksToBounds = YES;
    sureButton.backgroundColor = kButtonDefaultColor;
    [self.alertView addSubview:sureButton];
    [sureButton setImgRightTitltLeft:10];
    
    self.fullNameFiled.text = esString(self.nameStr);
    self.IDNoFiled.text = esString(self.idNoStr);
    self.DateFiled.text = esString(self.dateStr);
    
}

- (void)showBottomView{
    kWeakSelf
    [UIView animateWithDuration:0.25 animations:^{
        
        weakSelf.alertView.frame = CGRectMake(0, kScreenHeight - kWholeViewHeight, kScreenWidth, kWholeViewHeight);
         
     } completion:^(BOOL finished) {}];
    
}

- (void)clickCacel{
    [self endEditing:YES];
    kWeakSelf
    [UIView animateWithDuration:0.25 animations:^{
        
         weakSelf.alertView.frame = CGRectMake(0, kScreenHeight, kScreenWidth, kWholeViewHeight);
         
    } completion:^(BOOL finished) {
        
        [self removeFromSuperview];
        
        [[NSNotificationCenter defaultCenter] removeObserver:self name:kNotificationHideAlertView object:nil];
        
    }];
}

- (void)clickDate{
    
    [self endEditing:YES];
    NSString *dateStr = [esString(self.DateFiled.text) stringByReplacingOccurrencesOfString:@"-" withString:@"/"];
    NSArray *dateArray = [esString(dateStr) componentsSeparatedByString:@"/"];
    
    if (dateArray.count == 3) {
        dateStr = [NSString stringWithFormat:@"%@/%@/%@",dateArray[2],dateArray[1],dateArray[0]];
    }
    
    YearMonthDayPickerView *picker = [[YearMonthDayPickerView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) withCurrentSelectYearMonthDayString:dateStr withkOriginYear:1950];
    [[UIApplication sharedApplication].keyWindow addSubview:picker];
    [picker showBottomView];
    
    picker.callBackSelectDateBlock = ^(NSString * _Nonnull dateString) {
        
        NSArray *dateArray = [esString(dateString) componentsSeparatedByString:@"/"];

        if (dateArray.count == 3) {
            self.DateFiled.text = [NSString stringWithFormat:@"%@/%@/%@",dateArray[2],dateArray[1],dateArray[0]];
        } else {
            self.DateFiled.text = esString(dateString);
        }
    };
   
   
    
    
}

- (void)clickConfirmBtn{
    if (PMStringIsEmpty(self.fullNameFiled.text)) {
        [BoxLoadingHelper showBoxWithMessage:ASLocalizedString(@"Aadhaar Name")];
        return;
    }
    if (PMStringIsEmpty(self.IDNoFiled.text)) {
        [BoxLoadingHelper showBoxWithMessage:ASLocalizedString(@"Aadhaar Number")];
        return;
    }
    if (PMStringIsEmpty(self.DateFiled.text)) {
        [BoxLoadingHelper showBoxWithMessage:ASLocalizedString(@"Birthday")];
        return;
    }
   
    if (_callBackInfoStr) {
        _callBackInfoStr(self.fullNameFiled.text,self.IDNoFiled.text,self.DateFiled.text);
    }

}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/



@end
